<template>
  <div class="detailNav">
    <nav-bar>
      <div slot="left" class="left" @click="goBack">
          <img src="~assets/image/common/back.png" alt="">
      </div>
      <div slot="center" class="center">
        <div
          slot="center"
          v-for="(item, index) in titles"
          :key="index"
          class="detailItem"
          :class="{active:currentIndex===index}"
          @click="itemClick(index)"
        >
          {{ item }}
        </div>
      </div>
    </nav-bar>
  </div>
</template>

<script>
import NavBar from "components/common/navbar/NavBar.vue";
export default {
  data() {
    return {
      titles: ["商品", "参数", "评论", "推荐"],
      currentIndex:0
    };
  },
  name: "DetailNav",
  components: {
    NavBar,
  },
  methods:{
      itemClick(index){
          this.currentIndex=index
          this.$emit('tabClick',index)
      },
      goBack(){
          this.$router.back()
      }
  }
};
</script>

<style scoped>
.center {
  display: flex;
}
.detailItem {
  flex: 1;
  font-size: 16px;
}
.left img{
    width:16px;
    height: 16px;
}
</style>